Skip to content

Add MFA support for azd #42488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Add MFA support for azd #42488

wants to merge 2 commits into from

Conversation

xiangyan99
Copy link
Member

For AzdCredential, upon receiving claims during the get_token call, we need to invoke azd auth token --claims <claims_challenge> to allow Azd to store the claims.

Subsequently, we notify the user to run azd auth login again to re-authenticate.

@xiangyan99 xiangyan99 marked this pull request as ready for review August 13, 2025 23:59
@Copilot Copilot AI review requested due to automatic review settings August 13, 2025 23:59
@xiangyan99 xiangyan99 requested review from pvaneck and a team as code owners August 13, 2025 23:59
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds Multi-Factor Authentication (MFA) support for the Azure Developer CLI credential by implementing claims handling in both sync and async versions of AzureDeveloperCliCredential.

Key changes:

  • Enables the claims parameter in get_token() methods to handle MFA challenges
  • Adds a new utility function to extract user-friendly error messages from azd CLI JSON output
  • Improves error handling by parsing structured error messages from azd CLI output

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
sdk/identity/azure-identity/azure/identity/aio/_credentials/azd_cli.py Async version - adds claims parameter support and improved error message extraction
sdk/identity/azure-identity/azure/identity/_credentials/azd_cli.py Sync version - implements claims parameter support and adds extract_cli_error_message utility function
Comments suppressed due to low confidence (1)

sdk/identity/azure-identity/azure/identity/_credentials/azd_cli.py:329

  • Use f-string formatting instead of .format() for consistency with the rest of the codebase. Replace with combined_text = f"{ex.output or ''}\n{ex.stderr or ''}"
        combined_text = "{}\n{}".format(ex.output or "", ex.stderr or "")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Untriaged
Development

Successfully merging this pull request may close these issues.

1 participant